namespace EyeSoft.ServiceLocator
{
	using System;
	using System.Collections.Generic;
	using System.Linq;
	using System.Web.Mvc;

	public abstract class DependencyContainer : ServiceLocator, IDependencyContainer
	{
		protected DependencyContainer(bool throwExceptionOnMissingComponent = true)
			: base(throwExceptionOnMissingComponent)
		{
		}

		object IDependencyResolver.GetService(Type serviceType)
		{
			return
				!Any(serviceType) ?
					null :
					GetInstance(serviceType);
		}

		IEnumerable<object> IDependencyResolver.GetServices(Type serviceType)
		{
			return
				!Any(serviceType) ?
					Enumerable.Empty<object>() :
					GetAllInstances(serviceType);
		}

		public abstract object GetInstance(Type serviceType, IDictionary<string, object> parameters);

		public abstract T GetInstance<T>(IDictionary<string, object> parameters);

		public abstract void Release(object obj);

		public abstract void Dispose();
	}
}